//JavaScript代码区域
layui.use(['layer', 'form', 'laydate', 'table'], function() {
	var classId= getUrlParam("classId");
	var layer = layui.layer,
		$ = layui.$,
		form = layui.form,
		laydate = layui.laydate,
		table = layui.table;
	$('#myStudentdd').html(classId+'班学生')
	//监听提交
	form.on('submit(formDemo)', function(data) {
		table.reload('idTest', {
		  where: data.field
		});
		return false;
	});
	//执行一个laydate实例
	laydate.render({
		elem: '#start',
		max: 0
	});
	laydate.render({
		elem: '#end',
		max: 0
	});
	
	//数据表格实例
	table.render({
		id: 'idTest',
		elem: '#demo',
		url: IP+'/api/teacher_eav/teacherLogin/myStudents/'+classId,
		height: '480',
		method: 'get',
		page: true,
		even: true,
		cols: [[
		    {field: 'classId', title: '班级', align:'center', width:130}
	       ,{field: 'sNo', title: '学号', align:'center', width:130}
	       ,{field: 'sName', title: '姓名', align:'center'}
	       ,{field: 'sSex', title: '性别', align:'center',width:100}
	       ,{field: 'sType', title: '类型', align:'center',width:100}
	    ]],
	   
	    request: {
		  pageName: 'page'
		  ,limitName: 'pageSize'
		},              
	    response:{
	    	  statusName: 'code'
			  ,statusCode: 200
			  ,msgName: 'msg'
			  ,countName: 'count'
			  ,dataName: 'data'
	    },
	    done:function(res, curr, count){
			layer.closeAll('loading');
			$("[data-field = 'sSex']").children().each(function() {
				if($(this).text()== 1) {
					$(this).html('男');
				} else if($(this).text() == 0) {
					$(this).html('女');
				}
			});
			$("[data-field = 'sType']").children().each(function() {
				if($(this).text()== 1) {
					$(this).html('在校');
				} else if($(this).text() == 2) {
					$(this).html('退学');
				}else if($(this).text() == 3) {
					$(this).html('休学');
				}
			});
			$('tr:first').css({'background-color': '#4BB2FF', 'color': '#fff','font-size': '80px'});
			refreshTableDict();
	    }
	});
	

	//更新表格字典信息
	function refreshTableDict(){
		var table_datas=$('#demo').siblings('.layui-form').children('.layui-table-box')
			.children('.layui-table-body').children('.layui-table').children('tbody').children('tr');

	}

});